package co.th.bjc.md.helper.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import co.th.bjc.md.dao.ImpRating;
import co.th.bjc.md.helper.entries.HelperDatabse;

public class ImpRatingHelper extends HelperDatabse{
	
	public ImpRating findImpByImpCode(Integer impCode) throws Exception{
		Connection con = null;
		PreparedStatement stmt = null;
		ResultSet rs = null;
		ImpRating imp = null;
		try {
			con = getConnection();
			stmt = con.prepareStatement(IMP.FIND_BY_IMP_CODE);
			stmt.setInt(1, impCode); 
			
			rs = stmt.executeQuery();
			if (rs.next()){
				imp = new ImpRating();
				imp.setImpCode(rs.getInt("imp_code"));
				imp.setImpName(rs.getString("imp_name"));
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		} finally {
			if (rs != null) rs.close();
			if (stmt != null) stmt.close();
			if (con != null) con.close();
		}
		return imp;
	}
}
